package com.chengqj.user.service;

import com.chengqj.user.entity.UserDO;
import com.chengqj.user.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class UserInfoService {
    /** [mongo] 用户 */
    @Autowired
    private UserRepository userRepository;

    public void save(UserDO userDO){
        userRepository.save(userDO);
    }

    public UserDO queryById(String id){
        Optional<UserDO> userOptional = userRepository.findById(id);
        if (userOptional.isPresent()){
            return userOptional.get();
        }
        return null;
    }
}
